package com.ruoyi.web.controller.aimp;

import com.ruoyi.aimp.domain.Aimp_Warnrecord;
import com.ruoyi.aimp.service.IAimp_WarnrecordService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 警告信息Controller
 *
 * @author fengfeng
 * @date 2022-06-18
 */
@RestController
@RequestMapping("/ruoyi-aimp/warnrecord")
public class Aimp_WarnrecordController extends BaseController
{
    @Autowired
    private IAimp_WarnrecordService aimp_WarnrecordService;

    /**
     * 查询警告信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(Aimp_Warnrecord aimp_Warnrecord)
    {
        startPage();
        List<Aimp_Warnrecord> list = aimp_WarnrecordService.selectAimp_WarnrecordList(aimp_Warnrecord);
        return getDataTable(list);
    }

    /**
     * 导出警告信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnrecord:export')")
    @Log(title = "警告信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Aimp_Warnrecord aimp_Warnrecord)
    {
        List<Aimp_Warnrecord> list = aimp_WarnrecordService.selectAimp_WarnrecordList(aimp_Warnrecord);
        ExcelUtil<Aimp_Warnrecord> util = new ExcelUtil<Aimp_Warnrecord>(Aimp_Warnrecord.class);
        util.exportExcel(response, list, "警告信息数据");
    }

    /**
     * 获取警告信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnrecord:query')")
    @GetMapping(value = "/{warnrecordId}")
    public AjaxResult getInfo(@PathVariable("warnrecordId") Long warnrecordId)
    {
        return AjaxResult.success(aimp_WarnrecordService.selectAimp_WarnrecordByWarnrecordId(warnrecordId));
    }

    /**
     * 新增警告信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnrecord:add')")
    @Log(title = "警告信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Aimp_Warnrecord aimp_Warnrecord)
    {
        return toAjax(aimp_WarnrecordService.insertAimp_Warnrecord(aimp_Warnrecord));
    }

    /**
     * 修改警告信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnrecord:edit')")
    @Log(title = "警告信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Aimp_Warnrecord aimp_Warnrecord)
    {
        return toAjax(aimp_WarnrecordService.updateAimp_Warnrecord(aimp_Warnrecord));
    }

    /**
     * 删除警告信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-aimp:warnrecord:remove')")
    @Log(title = "警告信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warnrecordIds}")
    public AjaxResult remove(@PathVariable Long[] warnrecordIds)
    {
        return toAjax(aimp_WarnrecordService.deleteAimp_WarnrecordByWarnrecordIds(warnrecordIds));
    }
}
